﻿using Haidou.Wpf.Domian.Todo;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Haidou.Wpf.UI.Windows.Composer
{
	/// <summary>
	/// 待办助手，支持创建待办事项和计划。  超时提醒，周期性提醒等功能。语音提醒，桌面提醒等功能。
	/// </summary>
	public partial class To_DoPlanAssistant : Window
	{
		public To_DoPlanAssistant()
		{
			InitializeComponent();
		}

		private void Card_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
		{
			if (sender is Border bd && bd.Tag is TodoItem item && DataContext is ToDoPlanAssistantViewModel vm)
			{
				vm.Selected = item;
				CommandManager.InvalidateRequerySuggested();
			}
		}

		private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
			if (e.ClickCount == 2)
			{
				ToggleMaximize();
				return;
			}
			if (e.ButtonState == MouseButtonState.Pressed)
			{
				try { DragMove(); } catch { }
			}
		}

		private void BtnMin_Click(object sender, RoutedEventArgs e) => WindowState = WindowState.Minimized;
		private void BtnMax_Click(object sender, RoutedEventArgs e) => ToggleMaximize();
		private void BtnClose_Click(object sender, RoutedEventArgs e) => Close();
		private void ToggleMaximize() => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
	}
}
